Meteor in Action by Stephan Hochhaus Manuel Christoph Schoebel

Meteor in Action by Stephan Hochhaus Manuel Christoph Schoebel

Author:Stephan Hochhaus Manuel Christoph Schoebel
Language: eng
Format: mobi, pdf
Publisher: Manning Publications
Published: 2015-10-07T19:53:12.573000+00:00


When the application first starts, the Session variable limit is set to 10 because it doesn’t have any other value. This is what setDefault does and it ensures that limit will always have a value.

The reason you need to put the subscription inside a Tracker.autorun is to create a reactive context. Once the Session variable limit changes, the subscription to workouts gets rerun with the updated limit value. This means whenever the limit value changes, triggered by an event or directly from the JavaScript console, the subscription is updated automatically. Then the new data from the publication is added to the client’s Minimongo and also rendered in the template.

To allow for a more convenient way to increase the number of documents to show, you can add a button with a click handler that adds 10 to the current limit value in the Session object (see following listing).

Listing 7.5. Adding an event handler to increase the limit by 10



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.